package com.gscitysfy.cus.drain.modules.resource.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gscitysfy.cloudfrmwk.assistant.domain.Result;
import com.gscitysfy.cus.drain.modules.command.dto.IPageDto;
import com.gscitysfy.cus.drain.modules.resource.dto.ResourceCarDto;
import com.gscitysfy.cus.drain.modules.resource.service.IResourceCarService;
import com.gscitysfy.cus.drain.modules.resource.vo.ResourceCarQuery;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 防汛车辆表 前端控制器
 * </p>
 *
 * @author Administrator
 * @since 2022-10-23 15:27:02
 */
@Tag(name = "资源管理 -> 泵车管理")
@AllArgsConstructor
@RestController
@RequestMapping("/resource/car")
public class ResourceCarController {

    private final IResourceCarService iResourceCarService;

    @Operation(summary = "获取泵车管理列表")
    @GetMapping("/list")
    public Result<IPage<ResourceCarDto>> pageList(IPageDto page, ResourceCarQuery query) {
        return Result.content(iResourceCarService.fetchPage(page.getPage(), query));
    }

    @Operation(summary = "获取泵车详情")
    @GetMapping("/{cmKid}")
    public Result<ResourceCarDto> getById(@PathVariable Long cmKid) {
        return Result.content(iResourceCarService.getById(cmKid));
    }

    @Operation(summary = "获取泵车GIS列表")
    @GetMapping("/gis")
    public Result<List<ResourceCarDto>> gisList() {
        return Result.content(iResourceCarService.fetchGis());
    }

    @Operation(summary = "新增泵车管理")
    @PostMapping
    public Result<Boolean> save(@RequestBody @Validated ResourceCarDto dto) {
        return Result.content(iResourceCarService.saveOrUpdate(dto));
    }

    @Operation(summary = "修改泵车管理")
    @PutMapping
    public Result<Boolean> update(@RequestBody @Validated ResourceCarDto dto) {
        return Result.content(iResourceCarService.saveOrUpdate(dto));
    }

    @Operation(summary = "删除泵车管理")
    @PutMapping(value = "/delete")
    public Result<Boolean> delete(@RequestBody List<Long> idList) {
        return Result.content(iResourceCarService.delete(idList));
    }

}
